#include<unordered_map>
#include "tcp_server.hpp"

std::unordered_map<std::string,std::string> g_dict;

void Translate(const std::string& req,std::string* resp)
{
	auto it = g_dict.find(req);
	if(it == g_dict.end())
	{
		*resp = "未找到";
		return;
	}
	*resp = it->second;
	return;
}

int main(int argc,char* argv[])
{
	if(argc != 3)
	{
		std::cout<<"参数不足,---./server ip port"<<std::endl;
		return 1;
	}
	g_dict.insert(std::make_pair("hello","你好"));
	g_dict.insert(std::make_pair("bit","比特"));
	g_dict.insert(std::make_pair("world","世界"));
	g_dict.insert(std::make_pair("cpp","最棒的语言"));
	
	TcpServer server(argv[1],atoi(argv[2]));
	server.Start(Translate);
	return 0;
}
